
This resource address creates a new trigger.
| URL Parameters | |
|---|---|
| format | The format of the data in the request body. Allowed
values: html, json or xml (default). Use this
parameter to override the Accept header. |
Upon success, MarkLogic Server returns status code 200 (OK). If the trigger already exists or if the payload is malformed, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.
manage-admin rolehttp://marklogic.com/xdmp/privileges/manage-admin
http://marklogic.com/xdmp/privileges/manage
http://marklogic.com/xdmp/privileges/create-trigger and
http://marklogic.com/xdmp/privileges/manageprivilege, plus one of the following privileges:
http://marklogic.com/xdmp/privileges/admin/databasehttp://marklogic.com/xdmp/privileges/admin/database/database-IDhttp://marklogic.com/xdmp/privileges/admin/database/triggers/database-IDhttp://marklogic.com/xdmp/privileges/admin/database/database-namehttp://marklogic.com/xdmp/privileges/admin/database/triggers/database-nameThe structure of the data in a create trigger request is as shown below.
idnamedescriptioneventThis is a complex structure with the following children:
data-eventThis is a complex structure with the following children:
document-scopeThis is a complex structure with the following children:
uricollection-scopeThis is a complex structure with the following children:
uridirectory-scopeThis is a complex structure with the following children:
uridepthdocument-contentThis is a complex structure with the following children:
update-kindany-property-contentany-custom-property-contentproperty-contentThis is a complex structure with the following children:
property-nameThis is a complex structure with the following children:
namespace-urilocalnamewhendatabase-online-eventThis is a complex structure with the following children:
useruser-iduser-namemodulemodule-dbmodule-rootenabledrecursivetask-prioritypermissionsThis is a complex structure with the following children:
permissionThis is a complex structure with the following children:
role-namecapability
curl -X POST --anyauth --user admin:admin --header "Content-Type:application/json" \
-d '{
"name": "my-trigger",
"description": "my trigger",
"event": {
"data-event": {
"directory-scope": {
"uri": "/myDir/",
"depth": "1"
},
"document-content": {
"update-kind": "create"
},
"when": "post-commit"
}
},
"module": "/test.xqy",
"module-db": "Modules",
"module-root": "/modules/",
"enabled": true,
"recursive": true,
"task-priority": "normal"
}' \
http://localhost:8002/manage/v2/databases/myTriggers/triggers
==> Creates a new trigger, named "my-trigger," for the myTriggers
database.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.